package Chapter5;

import java.util.Objects;

public final class Dog extends Animal {
    private double price;
    private String owner;

    public Dog() {
        super("狗","宠物");
    }

    public Dog(double price, String owner) {
        super("狗","宠物");
        this.price = price;
        this.owner = owner;
    }
    //覆盖
    public void setPingzhong() {
        super.setPingzhong("狗");
    }
    public Dog(String pingzhong, String leibie, double price, String owner) {
        super(pingzhong, leibie);
        this.price = price;
        this.owner = owner;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Dog dog = (Dog) o;
        return Double.compare(dog.price, price) == 0 &&
                Objects.equals(owner, dog.owner);
    }

    @Override
    public int hashCode() {
        return Objects.hash(price, owner);
    }

    @Override
    public String toString() {
        return "Dog{" +
                "price=" + price +
                ", owner='" + owner + '\'' +
                '}';
    }
}
